<?php
/**
*Smarty plugin
*@package Smarty_ams
*@subpackage plugins
*
*@author:Liu Zhongjie<neojie@263.net>
*@coperation:Beijing Arouter Software Co.Ltd
*@creat Date:2007/07/30
**/

/**
* Smarty {html_banner_ams} function plugin
*
* Type:    function
* Name:    html_banner_ams
* Date:    July 30,2007
* Input:<br>
*         -font         = 文字
*         -button       = 按钮
*         -bannerstyle  = banner条的外观样式
*         -buttonstyle  = 按钮的外观样式
*
* Examples:
* <pre>
* <{html_banner_ams font=$FONT button=$BUTTON}>
* </pre>
* @param array
* @param Smarty
* @return string
**/

function smarty_function_html_banner_ams ($params, &$smarty)
{
	require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
	
	$aFont         = null;
	$aButton       = null;
//	$sBannerStyle  = null;
//	$sBtnStyle     = null;
	foreach($params as $_key => $_value)
	{
		switch($_key)
		{
			case 'font':
                $aFont = (array)$_value;
                break;
            case 'button':
             	$aButton = (array)$_value;
            	break;
            default:
            	$aFont   = array();
            	$aButton = array();
            	break;

/*
            case 'bannerstyle':
            	$sBannerStyle = (string)$_value;
            	break;
            case 'buttonstyle1':
            	$sBtnStyle = (string)$_value;
            	break;
*/
		}
	}
	$sOutput     = '<table width="100%" class="banner" border="0">'."\n";
	$sOutput    .= '<tr>'."\n\t";
	$sOutput    .= '<td valign="top">'."\n\t\t";
	
	if (count($aFont) >1)
	{
		$sOutput.= '<font style="color:#666;">'.smarty_function_escape_special_chars($aFont[0]).'</font>'."\n\t\t";
		$sOutput.= '<font style="color:#666;">'.smarty_function_escape_special_chars($aFont[1]).'</font>'."\n\t\t";
		for($i=2;$i < count($aFont);$i++)
		{
			$sOutput.= '<font class="arrow">>></font>'."\n\t\t";
			if($i == count($aFont)-1)
			{
				$sOutput.= '<font style="font-weight:bold;">';
			}
			else
			{
				$sOutput.= '<font style="color:#666;">'; 
			}
			$sOutput.= smarty_function_escape_special_chars($aFont[$i]).'</font>'."\n\t";
		}		
	}
	
	$sOutput.= '</td>'."\n\t";
	$sOutput.= '<td align="right">'."\n\t\t";
	
	    
	for($i=0;$i < count($aButton);$i++)
	{
		$sOutput    .= '<input name="'.$aButton[$i]["name"].'" type="button" value="'.$aButton[$i]["value"].'" '."\n\t\t";
		$sOutput    .= 'class="blue_button1" onClick="'.$aButton[$i]["script"].';" '."\n\t\t";
		$sOutput    .= "onmouseover=\"javascript:this.className='blue_button2';\" "."\n\t\t";
		$sOutput    .= "onmouseout=\"javascript:this.className='blue_button1';\" hideFocus />"."\n\t\t";
	}
	$sOutput    .= '</td>'."\n";
	$sOutput    .= '</tr>'."\n";
	$sOutput    .= '</table>';

	return $sOutput;
}
?>
